package com.bysj.yqsht.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeWeekUtil {
    public static String getWeekDay(Date date) {
        SimpleDateFormat sdFormat = new SimpleDateFormat("EEEE");
        return sdFormat.format(date);
    }

    public static String getWeekDay(String date, String format) {
        //这里的getDate在上面有写
        return getWeekDay(getDate(date, format));

    }

    public static String getDate(Date date, String format) {
        if (date == null) {
            return "";
        }
        SimpleDateFormat sdFormat = new SimpleDateFormat(format);

        return sdFormat.format(date);

    }

    public static Date getDate(String date, String format) {
        try {
            return new SimpleDateFormat(format).parse(date);
        } catch (Exception e) {
            //e.printStackTrace();
            return null;
        }
    }
}